package com.gylang.user.context.domain;

import cn.hutool.core.collection.CollUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author gylang
 * data 2020/9/2
 * @version v0.0.1
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class UserContextDTO {

    /**
     * 用户id
     */
    private String uid;
    /**
     * 昵称
     */
    private String nickName;

    /**
     * 用户名
     */
    private String username;



    /**
     * 角色列表
     */
    @Builder.Default
    private List<RoleDTO> roleList = new ArrayList<>();

    /**
     * 权限列表
     */
    @Builder.Default
    private List<RightDTO> rightList = new ArrayList<>();

    /**
     * 缓存用户数据
     */
    @Builder.Default
    private Map<String, Object> attr = CollUtil.newHashMap();


    public void addRole(RoleDTO roleDTO) {
        roleList.add(roleDTO);
    }
    public void addRight(RightDTO rightDTO) {
        rightList.add(rightDTO);
    }

    public void addAttr(String key, Object value) {
        attr.put(key, value);
    }
}
